﻿using MudBlazor.Utilities;

namespace MXERP.Blazor.Components
{
    internal class Cell<T>
    {
        private readonly Column<T> _column;
        private readonly TableRow<T> _row;
        internal CellContext<T> _cellContext;

        #region Computed Properties

        internal object? ComputedValue
        {
            get
            {
                return _column.CellContent(_row.Item);
            }
        }

        internal string ClassName
        {
            get
            {
                return new CssBuilder("md-table-cell")
                    .AddClass(_column.CalcFixedClass())
                    //.AddClass("sticky-left", _column.StickyLeft)
                    //.AddClass("sticky-right", _column.StickyRight)
                    .Build();
            }
        }
        //internal string computedStyle
        //{
        //    get
        //    {
        //        return new StyleBuilder()
        //            .AddStyle(_column.CellStyleFunc?.Invoke(_item))
        //            .AddStyle(_column.CellStyle)
        //            .Build();
        //    }
        //}

        #endregion

        public Cell(TableRow<T> row, Column<T> column)
        {
            _row = row;
            _column = column;
            // Create the CellContext
            _cellContext = new CellContext<T>(row);
        }
    }
}
